package com.atguigu.cloudalibaba.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RestController
@RefreshScope
public class OrderController {


    @Value("${service-url.nacos-user-service}")
    private String serviceUri;

    @Autowired
    private RestTemplate restTemplate;

    @RequestMapping("/consumer/server/port")
    public String getServiceUri() {
        ResponseEntity<String> forEntity = restTemplate.getForEntity(serviceUri + "/server/port", String.class);
        return "状态："+forEntity.getStatusCode().toString()+"返回结果："+forEntity.getBody().toString();
    }
}
